home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1993…ch: Other People's Memory / ADC Developer CD (1993-03) (''Other People's Memory'')_iso / Dev.CD Mar 93.iso / Technical Documentation / Sample Code / DTS.Lib & Samples / DTS.Chat / DoEvent.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-10-22  |  3.5 KB  |  174 lines  |  [TEXT/MPS ]

  1. /*
  2. ** Apple Macintosh Developer Technical Support
  3. **
  4. ** File:        DoEvent.c
  5. ** Written by:    Eric Soldan
  6. **
  7. ** Copyright © 1990-1991 Apple Computer, Inc.
  8. ** All rights reserved.
  9. */
  10.  
  11.  
  12.  
  13. /*****************************************************************************/
  14.  
  15.  
  16.  
  17. #include "App.h"            /* Get the application includes/typedefs, etc.    */
  18. #include "App.Common.h"        /* Get the stuff in common with rez.            */
  19. #include "App.protos.h"        /* Get the prototypes for application.            */
  20.  
  21. #ifndef __CTLHANDLER__
  22. #include "CtlHandler.h"
  23. #endif
  24.  
  25. #ifndef __DESK__
  26. #include <Desk.h>
  27. #endif
  28.  
  29. #ifndef __DISKINIT__
  30. #include <DiskInit.h>
  31. #endif
  32.  
  33. #ifndef __ERRORS__
  34. #include <Errors.h>
  35. #endif
  36.  
  37. #ifndef __MENUS__
  38. #include <Menus.h>
  39. #endif
  40.  
  41. #ifndef __TEXTEDITCONTROL__
  42. #include "TextEditControl.h"
  43. #endif
  44.  
  45. #ifndef __TOOLUTILS__
  46. #include <ToolUtils.h>
  47. #endif
  48.  
  49. #ifndef __UTILITIES__
  50. #include "Utilities.h"
  51. #endif
  52.  
  53.  
  54.  
  55. /*****************************************************************************/
  56.  
  57.  
  58.  
  59. extern CursPtr    gCursorPtr;
  60.     /* See the file Window2.c for comments about this global. */
  61.  
  62.  
  63.  
  64. /*****************************************************************************/
  65. /*****************************************************************************/
  66.  
  67.  
  68.  
  69. /* Do the right thing for an event.  Determine what kind of event it is, and
  70. ** call the appropriate routines. */
  71.  
  72. #pragma segment Main
  73. void    DoEvent(EventRecord *event)
  74. {
  75.     WindowPtr        window;
  76.     Point            pt;
  77.     OSErr            err;
  78.     TEHandle        teHndl;
  79.  
  80.     switch(event->what) {
  81.  
  82.         case nullEvent:
  83.             DoIdleTasks(event);
  84.             break;
  85.  
  86.         case mouseDown:
  87.             DoMouseDown(event);
  88.             break;
  89.  
  90.         case autoKey:
  91.         case keyDown:                    /* Check for menukey equivalents. */
  92.             DoKeyDown(event);
  93.             break;
  94.  
  95.         case activateEvt:
  96.             gCursorPtr = nil;            /* Force recalculation of the cursor. */
  97.             DoActivate((WindowPtr)event->message);
  98.             break;
  99.  
  100.         case updateEvt:
  101.             DoUpdate((WindowPtr)event->message);
  102.             break;
  103.  
  104.         case kHighLevelEvent:
  105.             gCursorPtr = nil;            /* Force recalculation of the cursor. */
  106.             DoHighLevelEvent(event);
  107.             break;
  108.  
  109.         case osEvt:
  110.             gCursorPtr = nil;            /* Force recalculation of the cursor. */
  111.             switch ((event->message >> 24) & 0xFF) {
  112.                     /* Must logical and with 0xFF to get only low byte. */
  113.                     /* High byte of message. */
  114.  
  115.                 case mouseMovedMessage:
  116.                     break;
  117.  
  118.                 case suspendResumeMessage:
  119.                         /* Suspend/resume is also an activate/deactivate. */
  120.                     gInBackground = !((event->message) & resumeFlag);
  121.                     CTEConvertClipboard((event->message) & convertClipboardFlag, !gInBackground);
  122.                     DoActivate(FrontWindow());
  123.                     HiliteWindows();
  124.                     break;
  125.             }
  126.             break;
  127.  
  128.         case diskEvt:
  129.             gCursorPtr = nil;            /* Force recalculation of the cursor. */
  130.             if (HiWord(event->message) != noErr) {
  131.                 SetPt(&pt, kDILeft, kDITop);
  132.                 err = DIBadMount(pt, event->message);
  133.             }
  134.             break;        /* It is not a bad idea to at least call DIBadMount
  135.                         ** in response to a diskEvt, so that the user can
  136.                         ** format a floppy. */
  137.     }
  138.  
  139.     DoCursor();
  140.     DoAdjustMenus();
  141.  
  142.     if (teHndl = CTEFindActive(nil)) {
  143.         BeginContent(window = (*teHndl)->inPort);
  144.         CTEIdle();
  145.         EndContent(window);
  146.     }
  147. }
  148.  
  149.  
  150.  
  151. /*****************************************************************************/
  152.  
  153.  
  154.  
  155. /* This is called when a window is activated or deactivated. */
  156.  
  157. #pragma segment Main
  158. void    DoActivate(WindowPtr window)
  159. {
  160.     NotifyCancel();
  161.  
  162.     if (IsAppWindow(window)) {
  163.         SetPort(window);
  164.         DoCtlActivate(window);
  165.         DoDrawFrame(window);            /* Redraw window scrollbars and growIcon, if any. */
  166.         BeginContent(window);
  167.         DoDrawControls(window, true);    /* Redraw content scrollbars. */
  168.         EndContent(window);
  169.     }
  170. }
  171.  
  172.  
  173.  
  174.